package com.example.lvsuo.controller;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.example.lvsuo.entity.HrEmp;
import com.example.lvsuo.entity.HrTeam;
import com.example.lvsuo.entity.SystemUser;
import com.example.lvsuo.entity.SystemUserRole;
import com.example.lvsuo.entity.vo.HrTeamVo;
import com.example.lvsuo.entity.vo.SystemUserVo;
import com.example.lvsuo.modal.Result;
import com.example.lvsuo.service.IHrTeamService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 团队信息 前端控制器
 * </p>
 *
 * @author 心心念念
 * @since 2021-03-30
 */
@RestController
@RequestMapping("/hrTeam")
public class HrTeamController {

    @Autowired
    IHrTeamService iHrTeamService;

    /**
     * 查询团队表
     * @param hrTeamVo
     * @return
     */
    @GetMapping
    public Result getHrTeam(HrTeamVo hrTeamVo){
        PageHelper.startPage(hrTeamVo.getPageId(),hrTeamVo.getPageNum());
        PageInfo pageInfo = new PageInfo(iHrTeamService.getHrTeam(hrTeamVo));
        return Result.back("ok","200",pageInfo);
    }

    /**
     * 根据id查询用户详情
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result getHrTeamId(@PathVariable String id) {
        List<HrTeam> list = iHrTeamService.getHrTeamId(id);
        return Result.back("ok", "200", list);
    }

    /**
     * 添加
     *
     * @param hrTeam
     * @return
     */
    @PostMapping
    Result addHrTeam(@RequestBody HrTeam hrTeam) {
            iHrTeamService.save(hrTeam);
            return Result.back("ok", "200");
    }

    /**
     * 修改
     *
     * @param hrTeam
     * @return
     */
    @PutMapping
    Result updateHrTeam(@RequestBody HrTeam hrTeam) {
        System.out.println(hrTeam);
        iHrTeamService.updateById(hrTeam);//添加用户
        return Result.back("ok", "200");
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public Result deleteHrTeam(@PathVariable String id){
        iHrTeamService.removeById(id);
        return Result.back("ok","200");
    }


}

